package com.hxm.demo.netty.http_demo;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器，得到管道
        ChannelPipeline pipeline = ch.pipeline();

        //HttpServerCodec是netty提供处理http的解码器
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());

        //增加一个自定义handler
        pipeline.addLast("myTestHttpServerHandler",new TestHttpServerHandler());

        System.out.println("ok...........");
    }
}
